<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib prefix="a4j" uri="https://ajax4jsf.dev.java.net/ajax"%>
<%@taglib prefix="r" uri="http://richfaces.org/rich"%>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Untitled Document</title>
        <style type="text/css">@import url("../../css/style.css");</style>
        <script type="text/javascript" language="javascript">

            function trava(){

                var flag = document.getElementById("form:flagPerfil").value;


                if (flag == 4)
                {
                    alert("Ação Negada! Você não tem permissão para realizar isso.");
                    return false;
                }
                else
                {
                    return true;
                }
            }
        </script>
    </head>
    <body>
        <div align="center">
            <f:view>
                <a4j:form id="form">
                    <r:messages id="msgs" styleClass="msg"/>
                    <table width="740" border="0" align="center">
                        <tr>
                            <td width="735" height="30" class="style1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Consultar Pessoas Físicas</td>
                        </tr>
                        <tr class="style2">
                            <td><table width="730" border="0" align="center">
                                    <tr>
                                        <td height="32" colspan="4"><div align="center"><h:inputText id="buscaPF" required="false" value="#{PessoaPFBean.valorBusca}" styleClass="border" onkeyup="javascript:this.value=this.value.toUpperCase();" size="60"></h:inputText>&nbsp;<h:commandButton id="pesquisa" value="Pesquisar" styleClass="style2" action="#{PessoaPFBean.pesquisaPF}"/></div></td>
                                    </tr>
                                    <tr>
                                        <td height="32" colspan="6"><div align="center">
                                                <h:selectOneRadio id="tipoBusca" value="#{PessoaPFBean.param}" styleClass="style2">
                                                    <f:selectItem itemValue="Nome" itemLabel="Nome"></f:selectItem>
                                                    <f:selectItem itemValue="RG" itemLabel="RG"></f:selectItem>
                                                    <f:selectItem itemValue="CPF" itemLabel="CPF"></f:selectItem>
                                                    <f:selectItem itemValue="Codigo" itemLabel="Codigo"></f:selectItem>
                                                </h:selectOneRadio></div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="4"><h:inputHidden id="flagPerfil" value="#{Login.usuarioEventoPerfil.perfil.codigo}"/></td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <r:datascroller id="scFisica" align="center" for="listaFisica" maxPages="20"/>
                                            <r:dataTable id="listaFisica" align="center" width="730" rows="9" value="#{PessoaPFBean.pfje}" var="listagemFisica" columnClasses="link" rowClasses="row, row2">
                                                <f:facet name="header">
                                                    <r:columnGroup columnClasses="" style="align:center;">
                                                        <r:column width="50">
                                                            <h:outputText styleClass="headerText" value="Código" />
                                                        </r:column>
                                                        <r:column width="80">
                                                            <h:outputText styleClass="headerText" value="CPF" />
                                                        </r:column>
                                                        <r:column width="100">
                                                            <h:outputText styleClass="headerText" value="Nome Completo" />
                                                        </r:column>
                                                        <r:column width="100">
                                                            <h:outputText styleClass="headerText" value="Empresa" />
                                                        </r:column>
                                                        <r:column width="50">
                                                            <h:outputText styleClass="headerText" value="Opções" />
                                                        </r:column>
                                                    </r:columnGroup>
                                                </f:facet>
                                                <r:column style="text-align:center">
                                                    <h:outputText value="#{listagemFisica.pessoaFisica.codigo}" />
                                                </r:column>
                                                <r:column style="text-align:center">
                                                    <h:outputText value="#{listagemFisica.pessoaFisica.cpf}" />
                                                </r:column>
                                                <r:column style="text-align:center">
                                                    <h:outputText value="#{listagemFisica.pessoaFisica.nome}" />
                                                </r:column>
                                                <r:column style="text-align:center">
                                                    <h:outputText value="#{listagemFisica.pessoaJuridica.nomeFantasia}">
                                                        
                                                    </h:outputText>
                                                </r:column>
                                                <r:column style="text-align:center">                                                                                                        
                                                    <h:commandButton id="btnEditarPF" value="Editar" image="/jsp/imagens/alterar.png" action="#{PessoaPFBean.editar}" alt="Editar" onclick="return trava();"  >
                                                        <f:setPropertyActionListener value="#{listagemFisica}" target="#{PessoaPFBean.pessoaFisicaJuridica}" />

                                                    </h:commandButton>
                                                    <r:toolTip followMouse="true" styleClass="tooltip" value="Alterar Cadastro" for="btnEditarPF"/>
                                                    &nbsp;&nbsp;
                                                    <a4j:commandButton value="Reimprimir" image="/jsp/imagens/print.png" action="#{PessoaPFBean.reImprimirPF}" alt="Reimprimir">
                                                        <f:setPropertyActionListener value="#{listagemFisica.pessoaFisica.codigo}" target="#{PessoaPFBean.pessoaFisica.codigo}" />
                                                        <r:toolTip followMouse="true" styleClass="tooltip" value="Reimprimir Cracha"/>
                                                    </a4j:commandButton>
                                                    &nbsp;&nbsp;
                                                    <a4j:commandButton value="Reimprimir Cursos" image="/jsp/imagens/printCurso.png" action="#{CursoBean.reimpressao}" alt="Reimprimir">
                                                        <f:setPropertyActionListener value="#{listagemFisica.pessoaFisica.codigo}" target="#{CursoBean.pessoaFisica.codigo}" />
                                                        <r:toolTip followMouse="true" styleClass="tooltip" value="Reimprimir Cursos"/>
                                                    </a4j:commandButton> 
                                                    &nbsp;&nbsp;
                                                    &nbsp;&nbsp;
                                                    &nbsp;&nbsp;
                                                    <a4j:commandButton value="Excluir" image="/jsp/imagens/excluir.png" action="#{PessoaPFBean.excluir}" alt="Excluir" reRender="form">
                                                        <f:setPropertyActionListener value="#{listagemFisica.pessoaFisica.codigo}" target="#{PessoaPFBean.pessoaFisica.codigo}" />
                                                        <r:toolTip followMouse="true" styleClass="tooltip" value="Remover Cadastro"/>
                                                    </a4j:commandButton>
                                                    &nbsp;&nbsp;
                                                </r:column>
                                            </r:dataTable>
                                            <r:modalPanel id="loadPanel" autosized="true">
                                                <a4j:status id="load" onstop="#{r:component('loadPanel')}.hide()">
                                                    <f:facet name="start">
                                                        <h:graphicImage  value="/jsp/imagens/ajax-loader.gif"/>
                                                    </f:facet>
                                                </a4j:status>
                                            </r:modalPanel>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </a4j:form>
            </f:view>
        </div>
    </body>
</html>
